package com.lkd.controller;


import com.lkd.service.VendingMachineService;
import com.lkd.vo.PageBean;
import com.lkd.vo.Result;
import com.lkd.vo.VmListVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author author
 * @since 2024-08-20
 */
@RestController
public class VendingMachineController {
    @Autowired
    private VendingMachineService vendingMachineService;

    //获取点位详情
    @GetMapping("/api/vm-service/node/vmList/{nodeId}")
    public Result getVmList(@PathVariable Long nodeId){
        List<VmListVo> VmListVos = vendingMachineService.getVmList(nodeId);
        return Result.success(VmListVos);
    }

    //设备搜索
    @GetMapping("/api/vm-service/vm/search")
    public Result getByCode(String innerCode,
                            @RequestParam(defaultValue = "1")Integer pageIndex,
                            @RequestParam(defaultValue = "10")Integer pageSize){
        PageBean<VmListVo>page = vendingMachineService.getByCode(innerCode,pageIndex,pageSize);
        return Result.success(page);
    }

}
